import Excel from "exceljs";

// 获取工作簿
async function getWorkbook(file) {
  const workbook = new Excel.Workbook();
  return await workbook.xlsx.load(file);
}
// 获取工作表
function getWorksheet(workbook, sheetName) {
  return workbook.getWorksheet(sheetName);
}

// 获取工作表中的全部行
function getAllRow(worksheet) {
  let allRow = [];
  worksheet.eachRow({ includeEmpty: false }, function (row, rowNumber) {
    let tempRow = [...row.values];
    tempRow.shift();
    allRow.push(tempRow);
  });
  allRow.shift();
  return allRow;
}

export { getWorkbook, getWorksheet, getAllRow };
